package com.burnerpat.fl2d.core;

public class Timer
{
	private long lastEvent = 0;
	private long cooldown = 0;
	
	public Timer()
	{
		
	}
	
	public Timer(long pCooldown)
	{
		cooldown = pCooldown;
	}
	
	public void start()
	{
		lastEvent = Clock.getCurrentFrame();
	}
	
	public boolean isOver()
	{
		return (getRemainingTime() <= cooldown);
	}
	
	public long getCooldown()
	{
		return cooldown;
	}
	
	public void setCooldown(long pCooldown)
	{
		cooldown = pCooldown;
	}
	
	public long getRemainingTime()
	{
		return (Clock.getCurrentFrame() - lastEvent);
	}
	
	public double getPercentageLeft()
	{
		return ((double)getRemainingTime() / (double)cooldown);
	}
	
	public double getPercentageOver()
	{
		return (1.0 - getPercentageLeft());
	}
}
